package org.elanfox.intellicommunity.biz.dto.msg;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.elanfox.intellicommunity.biz.entity.msg.MsgBasePO;
import org.elanfox.intellicommunity.common.utils.Jsr310Utils;
import org.elanfox.intellicommunity.data.base.dto.BaseDTO;

import java.time.LocalDateTime;


/**
 * @author allan
 * @version 1.0.0
 * @date 2019/12/19
 */
@Data
@NoArgsConstructor
public class MsgBaseDTO implements BaseDTO {
    private static final long serialVersionUID = -831102678256354525L;

    private Long id;
    /**
     * 基站编号
     */
    private Long stationId;
    /**
     * 定位器编号
     */
    private Long locatorId;
    /**
     * 定位器位置
     */
    private String address;
    /**
     * 定位器在室内地图上的经度
     */
    private String longitude;
    /**
     * 定位器在室内地图上的纬度
     */
    private String latitude;
    /**
     * 是否楼层节点（如，电梯口，楼梯口等地）
     */
    private Boolean floorNode;
    /**
     * 对应社区位置
     */
    private Integer structureId;
    /**
     * 卡编号
     */
    private Long cardId;
    private String roomName;
    /**
     * 卡用户
     */
    private Integer userId;
    private String realName;
    /**
     * 房间号
     */
    private String roomNo;
    /**
     * 卡用户类型
     */
    private int userType;
    /**
     * 创建时间
     */
    private String createTime;

    private String imgUrl;

    private String userName;

    public MsgBaseDTO(MsgBasePO msgBasePO) {
        this.id = msgBasePO.getId();
        this.stationId = msgBasePO.getStationId();
        this.locatorId = msgBasePO.getLocatorId();
        this.address = msgBasePO.getLocatorInfo().getAddress();
        this.longitude = msgBasePO.getLocatorInfo().getLongitude();
        this.latitude = msgBasePO.getLocatorInfo().getLatitude();
        this.floorNode = msgBasePO.getLocatorInfo().getFloorNode();
        this.structureId = msgBasePO.getLocatorInfo().getStructureId();
        this.cardId = msgBasePO.getCardId();
        this.roomName = msgBasePO.getRoomName();
        this.userId = msgBasePO.getUserId();
        this.realName = msgBasePO.getRealName();
        this.userType = msgBasePO.getUserType().getCode();
        this.imgUrl = msgBasePO.getLocatorInfo().getImgUrl();
        this.createTime = Jsr310Utils.DateTime.asString(msgBasePO.getCreateTime());
    }

    public LocalDateTime createTime() {
        return Jsr310Utils.DateTime.of(createTime);
    }
}
